<?php
/**
 * User: colin
 * Date: 2017/2/20
 * Time: 15:27
 */

namespace App\Http\ViewComposers;


use App\Models\Column;
use App\Models\Config;
use App\Models\Upload;
use Colin\Util\Tree;
use Illuminate\View\View;

class DefaultComposer
{
    /**
     * Bind data to the view.
     *
     * @param  View $view
     * @return void
     */
    public function compose(View $view)
    {
        $tree = Tree::instance('id', 'parent_id', 'child');
        $columns = $tree->load(Column::all()->toArray())->deepTree();

        $hotline = Config::where('name', 'hotline')->first()->value;
        $logo = Upload::where('name', 'logo.gif')->first()->path();
        $company = \App\Models\Config::where('key', 'company')->first();
        $icp = \App\Models\Config::where('key', 'icp')->first();


        $view->with('navItems', $columns);
        $view->with(compact('hotline', 'logo','company', 'icp'));

    }
}